import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../author_logic.dart';
import '../../../shared/shared.dart';

class SelectGender extends StatelessWidget {
  const SelectGender(
      {Key? key,
      required this.iconNames,
      required this.gender,
      required this.controller,
      required this.select})
      : super(key: key);
  final IconNames iconNames;
  final String gender;
  final AuthorLogic controller;
  final int select;

  @override
  Widget build(BuildContext context) {
    return InkWell(
      highlightColor: Colors.transparent,
      radius: 0,
      onTap: () => changeGender(),
      child: Obx(() => _buildGender()),
    );
  }

  Row _buildGender() {
    return Row(
      crossAxisAlignment: CrossAxisAlignment.center,
      children: [
        Container(
            margin: const EdgeInsets.all(5),
            width: 20,
            height: 20,
            decoration: BoxDecoration(
                color: controller.state.gender.value == select
                    ? ColorConstants.selectColor
                    : Colors.transparent,
                shape: BoxShape.circle)),
        IconFont(iconNames, size: 36),
        Text(gender, style: const TextStyle(color: ColorConstants.themeColor, fontSize: 20))
      ],
    );
  }

  void changeGender() {
    if (gender == '男生') {
      controller.changeGender(select);
    } else {
      controller.changeGender(select);
    }
  }
}
